package com.jadeen.controller.serverController;


import com.jadeen.common.controller.BaseController;
import com.jadeen.common.domain.AjaxResult;
import com.jadeen.common.page.TableDataInfo;
import com.jadeen.entity.domain.Favorite;
import com.jadeen.service.IFavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户收藏Controller
 * 
 * @author jadeen
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/share/favorite")
public class FavoriteController extends BaseController
{
    @Autowired
    private IFavoriteService favoriteService;

    /**
     * 查询用户收藏列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Favorite favorite)
    {
        startPage();
        List<Favorite> list = favoriteService.selectFavoriteList(favorite);
        return getDataTable(list);
    }


    /**
     * 获取用户收藏详细信息
     */
    @GetMapping(value = "/{favoriteId}")
    public AjaxResult getInfo(@PathVariable("favoriteId") Long favoriteId)
    {
        return success(favoriteService.selectFavoriteByFavoriteId(favoriteId));
    }

    /**
     * 新增用户收藏
     */
    @PostMapping
    public AjaxResult add(@RequestBody Favorite favorite)
    {
        return toAjax(favoriteService.insertFavorite(favorite));
    }

    /**
     * 修改用户收藏
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Favorite favorite)
    {
        return toAjax(favoriteService.updateFavorite(favorite));
    }

    /**
     * 删除用户收藏
     */
	@DeleteMapping("/{favoriteIds}")
    public AjaxResult remove(@PathVariable Long[] favoriteIds)
    {
        return toAjax(favoriteService.deleteFavoriteByFavoriteIds(favoriteIds));
    }
}
